# Contributor: Karim Kanso <kaz.kanso@gmail.com>
# Maintainer: Karim Kanso <kaz.kanso@gmail.com>
pkgname=ettercap
pkgver=0.8.3.1
pkgrel=3
pkgdesc="Multipurpose sniffer/interceptor/logger for switched LAN"
url="https://www.ettercap-project.org/"
arch="all"
license="GPL-2.0-or-later"
makedepends="
	bison
	check-dev
	cmake
	curl-dev
	flex
	geoip-dev
	libnet-dev
	libpcap-dev
	linux-headers
	ncurses-dev
	pcre-dev
	samurai
	"
subpackages="$pkgname-doc lib$pkgname:libs"
source="https://github.com/Ettercap/ettercap/releases/download/v$pkgver/ettercap-$pkgver.tar.gz
	format-security.patch
	implicit-declaration.patch
	libcurl-8-ver-check.patch
	none-build-type.patch
	"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=None \
		$CMAKE_CROSSOPTS \
		-DENABLE_GTK=OFF \
		-DINSTALL_DESKTOP=OFF \
		-DBUNDLED_LIBS=OFF \
		-DENABLE_TESTS=ON

	cmake --build build
}

check() {
	ninja -C build test
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
5e3d79578e16b9a2a90a87dcd9b40696ac8dec439e017cbf60f209402e577e7563062769bb76a470d20d1a14269134b28d57d356380af6b5883e4824656b9807  ettercap-0.8.3.1.tar.gz
21527407d4743effe22c5b0623bbc3f68dffeec52b13d6a7b11dc3f89d19ce9c7df05104c2070dbe01bc2a0bdc679358cf7f788560fcb42e9da03ba14e20b896  format-security.patch
fa8565bc14c882b63405a0dcc459f2144ccaf41e622ba1da22edf5b4ca470c9f244c878576f271689eed7acbd49d63c356961de9b18b0a007ac6e22b07b67e9e  implicit-declaration.patch
c015e8da9cfd57e2501123497189d28f48f1e3840993464d779da7bdfc3223403420a16402bcd09fa8e2a008d26db5af65309e76973b683f914f29366b1baa9c  libcurl-8-ver-check.patch
9aae86ee1599b4ffa0b9c0c5acc7939675db12c02d53f0e47d6e18acc513c020e0dbc63812536f8d8716132e0f8aeaf2ff737b0c9d11e8d814074ded82093b7c  none-build-type.patch
"
